package org.andao.core.dao.helper;

import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.andao.core.utils.ExStringUtils;


/**
 * 列表查询参数.
 *  
 * @author Seewo software - Marco.hu(huzhiguo@cvte.cn)
 */
public class QueryParameter implements java.io.Serializable{

	private static final long serialVersionUID = -2967557667535464009L;
		
	private Map<String, Object> condition = new ConcurrentHashMap<String, Object>(0);//查询条件
	
		
	public QueryParameter(){}
	
	public QueryParameter(Map<String,Object> condition){
		this.condition = new ConcurrentHashMap<String, Object>(condition);		
	}
	
	public Map<String, Object> getCondition() {		
		if(null != condition && condition.size() > 0){//排空
			Iterator<?> it = condition.entrySet().iterator();
			while(it.hasNext()){
				Map.Entry entry = (Map.Entry) it.next();
				if(null == entry.getValue() || ExStringUtils.isBlank(entry.getValue().toString())){
					condition.remove(entry.getKey());
				}
			}
		}
		
		return this.condition;
	}
	
	public QueryParameter add(String key,Object value){
		this.condition.put(key, value);
		return this;
	}	
	
	public void setCondition(Map<String, Object> condition) {	
		this.condition = condition;
	}
	
}
